<?php

namespace Admin\Controller;
use User\Api\UserApi;

class BuffingController extends AdminController{
	
	public function index(){
		
       $info = M()
        ->table('one_buffing a,one_purchase b')
        ->where('a.purchase_id=b.id')
        ->field('a.*,b.status')
        ->order('status DESC')
        ->select();
        $this->assign("info",$info);
//      horns_status
//      dump($info);
		$this->display();
	}
	public function buffing_add($id){
				
          $info =  M("manufacture")->find($id);
          //状态
          $data= M('Purchase')->find($info["purchase_id"]);         
          $data['status'] = 3;
          $success = M('Purchase')->save($data);
          if($success){
          	$map["productNo"]   = $info["productNo"];
          	$map['purchase_id'] = $info["purchase_id"];
          	$map['goods_id']    = $info["goods_id"];
          	$map['product_id']  = $id;
          	$map["create_time"] = time();
          	M("Buffing")->add($map);
          	$this->success('添加成功');
          }       
                     	
	}
	public function search($id){
		
		 $info = M("Buffing")->find($id);
		 $this->ajaxReturn($info);
		  
	}
	public function add(){						
		$map["id"]                  = $_POST["buffing_id"];
		$map['buffing_contact_id']  = $_POST['buffing_contact_id'];
		$map['send_amount']         = $_POST['send_amount'];
		$map["waste_amount"]        = $_POST['waste_amount'];
		M("Buffing")->save($map);
	}
	public function delbuffing(){
		
		$id = $_POST['id'];
    	$info = M("Buffing")->find($id);
    	$info["is_delete"] = 1;
    	M("Buffing")->save($info);	
	
	}
}
?>